package com.scsj.supermarket.presenter;

import android.util.Log;

import com.orhanobut.logger.Logger;
import com.scsj.supermarket.base.IndexFuncBase;
import com.scsj.supermarket.bean.HomeClassifyBean;
import com.scsj.supermarket.bean.IndexTenFuncBean;
import com.scsj.supermarket.model.IndexTenFuncModel;

import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 *  首页十个功能键
 */

public class IndexFuncPresenter extends BasePresenter implements IndexFuncBase.IPresenter {

      private IndexFuncBase.IModel mModel;
      private IndexFuncBase.IView mView;

    public IndexFuncPresenter(IndexFuncBase.IView mView) {
        this.mView   = mView;
        mModel = new IndexTenFuncModel();
    }

    @Override
    public void deliverAllList(RequestBody requestBody) {

        addSubscription(mModel.getData(requestBody,new ResponseCallback<IndexTenFuncBean>() {
            @Override
            public void onSuccess(IndexTenFuncBean result) {

                if (result.getStatusCode() == 200) {

                    mView.showSuccessMsg("首页十个功能键获取成功了，sb");
                    mView.setAllData(result);
                    Logger.e("获取成功" + result.toString());
                } else {
                    mView.showErrorMsg(result.getMsg());
                    Logger.e("未成功" + result.toString());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Log.e("失败", msg + "");
            }
        }));

    }
}
